package nc.bs.so.invoice;

import java.util.ArrayList;

import nc.bs.scm.sn.pub.SnScmPubDMO;
import nc.vo.so.invoice.InvoiceCheckVO;
import nc.vo.uap.busibean.exception.BusiBeanException;

public class InvoiceCheckImpl  {

	public InvoiceCheckVO[] queryByCondition(String strWhere ,String careaid)
			throws BusiBeanException {
		InvoiceCheckVO[] vos=null;
		StringBuffer sql=new StringBuffer();
		  sql.append("select distinct h.ccustomerid,h.cmarketid,h.checkdate,sum(h.checknum) checknum "
		  ); 
		  if(careaid==null){
		  sql.append(" from so_inv_invoicecheck h  where"); }
		  else{sql.append(
		 "from  so_inv_invoicecheck h inner join bd_cumandoc m on h.cmarketid=m.pk_cumandoc inner join bd_cubasdoc b on m.pk_cubasdoc=b.pk_cubasdoc  where b. pk_areacl='"+careaid+"' and"); }
		sql.append(strWhere);
		sql.append("group by  h.ccustomerid, h.cmarketid, h.checkdate");
		
		try {
			SnScmPubDMO dmo= new SnScmPubDMO();
			ArrayList <InvoiceCheckVO>list =dmo.executeQuerySQL(sql.toString(), null,InvoiceCheckVO.class);
			vos=list.toArray(new InvoiceCheckVO[0]);
			return vos;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			throw new BusiBeanException(e.getMessage());
		}

	}

}
